package com.fgr.service.Impl;

import com.fgr.beans.AnimalType;
import com.fgr.mapper.AnimalMapper;
import com.fgr.mapper.AnimalTypeMapper;
import com.fgr.service.AnimalTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnimalTypeServiceImpl implements AnimalTypeService {
    @Autowired
    AnimalTypeMapper animalTypeMapper;

    @Autowired
    AnimalMapper animalMapper;


    @Override
    public List<AnimalType> selectAllAnimalType() {
        List<AnimalType> animalTypes = animalTypeMapper.selectAllAnimalType();
        return animalTypes;
    }

    @Override
    public AnimalType selectAnimalTypeById(Integer tyId) {
        AnimalType animalType = animalTypeMapper.selectAnimalTypeById(tyId);
        return animalType;
    }

    @Override
    public List<AnimalType> selectAllAnimalTypeByParentType(Integer tyParentId) {
        List<AnimalType> animalParentTypes = animalTypeMapper.selectAllAnimalTypeByParentType(tyParentId);
        return animalParentTypes;
    }

    @Override
    public List<AnimalType> selectAllAnimalChildType() {
        List<AnimalType> animalTypes = animalTypeMapper.selectAllAnimalChildType();
        return animalTypes;
    }

    @Override
    public Integer deleteAnimalType(Integer ty_id) {
        Integer integer = animalTypeMapper.deleteAnimalType(ty_id);
        return integer;
    }

    @Override
    public Integer deleteAnimalTypeByParentId(Integer ty_id) {
        Integer integer = animalTypeMapper.deleteAnimalTypeByParentId(ty_id);
        return integer;
    }

    @Override
    public String insertAnimalType(AnimalType animalType) {
        Integer integer = animalTypeMapper.insertAnimalType(animalType);
        if (integer>0){
            return "SUCCESS";
        }else {
            return "ERRO";
        }
    }
}
